package player;

import org.omg.CORBA.BooleanHolder;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StringHolder;

import common.CommonTools;
import frontend.FrontEnd;
import frontend.FrontEndHelper;

public class PlayerClientTest2 {

	public static void main(String[] args) {
		ORB orb = ORB.init(args, null);
		
		String playerIOR = CommonTools.getIOR("frontend", "frontend","client");
		System.out.println("IOR:"+playerIOR);
		
		org.omg.CORBA.Object FrontEndServiceObject = orb.string_to_object(playerIOR);
		
		FrontEnd frontEnd = FrontEndHelper.narrow(FrontEndServiceObject);
		
		String firstName = "Bill";
		String lastName = "Clinton";
		int age = 68;
		String userName = "Clinton"+args[1];
		String password = "bcbc1234";
		String clientIpAddress = "132.168.1.4";
		String newIpAddress = "93.168.1.4";
		
		//create account
		BooleanHolder result  = new BooleanHolder(); 
		StringHolder  status = new StringHolder(); 
		if (args[0].equals("C")){
			frontEnd.createPlayerAccount(firstName, lastName, (short) age, userName, password, clientIpAddress,result ,status);
		} else if (args[0].equals("I")){
			frontEnd.playerSignIn(userName, password, clientIpAddress,result ,status);
		} else if (args[0].equals("O")){
			frontEnd.playerSignOut(userName, clientIpAddress,result ,status);	
		} else if (args[0].equals("T")){
        frontEnd.transferAccount(userName, password, clientIpAddress,newIpAddress, result ,status);
		}
		
		CommonTools.writeLog("client","client",
				"remote call response is result:" + result.value + " status: "
						+status.value, "client");
		
	}

}
